package com.elitesland.metadata.service.impl;

import com.elitesland.metadata.convert.MetaCatTableConvert;
import com.elitesland.metadata.repo.MetaCatTableRepo;
import com.elitesland.metadata.service.MetaCatTableService;
import com.elitesland.metadata.vo.MetaCatTableVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * <pre>作用说明</pre>
 *
 * @author mir
 * @date 11/29/2020 1:12 AM
 */
@Service
public class MetaCatTableServiceImpl implements MetaCatTableService {

    private MetaCatTableRepo metaCatTableRepo;

    @Autowired
    public void setMetaCatTableRepo(MetaCatTableRepo metaCatTableRepo) {
        this.metaCatTableRepo = metaCatTableRepo;
    }

    @Override
    public Optional<MetaCatTableVO> oneById(Long id) {
        return metaCatTableRepo.findById(id).map(MetaCatTableConvert.INSTANCE::doToVO);
    }

    @Override
    public Optional<MetaCatTableVO> oneByCode(String code) {
        return metaCatTableRepo.findByDefCode(code).map(MetaCatTableConvert.INSTANCE::doToVO);
    }
}
